package edu.rakovic.elearning.pages;


import org.apache.tapestry5.annotations.SessionState;

import edu.rakovic.elearning.enums.Role;
import edu.rakovic.elearning.interfaces.User;

/**
 * Start page of application elearning.
 */
public class Index
{
	@SessionState
	private User user;

	private boolean userExists;
	
	public User getUser() {
		return user;
	}
	
	Object onActivate() {
		if (!userExists) return Login.class;
		return null;
	}
	
	public boolean isUserAdmin(){
		if(user.getRole() == Role.ADMINISTRATOR) return true;
		return false;
	}
	
	public boolean isUserTeacher(){
		if(user.getRole() == Role.TEACHER) return true;
		return false;
	}
	
	public boolean isUserStudent(){
		if(user.getRole() == Role.STUDENT) return true;
		return false;
	}
}
